﻿using UnityEngine;
using UnityEditor;
using System.IO;

public class XcodeProjectSettingCreator : EditorWindow
{
    [MenuItem("Assets/Create/XcodeProjectConfigCreate")]
    public static void CreateOneConfig()
    {
        string selectedPath = EditorUtility.OpenFolderPanel("Path", "Assets/Editor/IOSPorter/ChannelConfig", "");
        var start = selectedPath.LastIndexOf('/');
        var SDKName = selectedPath.Substring(start, selectedPath.Length - start);

        XCodeProjectConfig config = new XCodeProjectConfig();
        var jsonFile = JsonUtility.ToJson(config);
        string configPath =string.Format( "{0}/Editor/IOSPorter/ChannelConfig/{1}/{2}.json",Application.dataPath, SDKName, SDKName);
        File.WriteAllText(configPath, jsonFile);
        AssetDatabase.Refresh();
    }
}